package com.xbongbong.paas.help.menu;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.admin.pojo.dto.MirrorRollBackDTO;
import com.xbongbong.paas.constant.MessageConstant;
import com.xbongbong.paas.domain.entity.PaasAppEntity;
import com.xbongbong.paas.domain.entity.PaasFormEntity;
import com.xbongbong.paas.domain.entity.PaasMenuEntity;
import com.xbongbong.paas.enums.BIProductEnum;
import com.xbongbong.paas.enums.BIProductReformEnum;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.BusinessRulesPoJo;
import com.xbongbong.paas.pojo.dto.FormEntityAddDTO;
import com.xbongbong.paas.pojo.dto.FormExplainAddDTO;
import com.xbongbong.paas.pojo.dto.MenuGroupAddDTO;
import com.xbongbong.paas.service.PaasFormExplainService;
import com.xbongbong.paas.service.PaasFormService;
import com.xbongbong.paas.service.PaasMenuService;
import com.xbongbong.paas.service.init.AbstractInitMenuHelp;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.enums.menu.enums.ProductMenuEnum;
import com.xbongbong.pro.enums.menu.enums.SystemAppMenuEnum;
import com.xbongbong.pro.form.pojo.dto.FormAddBatchDTO;
import com.xbongbong.pro.form.pojo.vo.FormAddBatchVO;
import com.xbongbong.pro.formexplain.pojo.dto.FormExplainAddBatchDTO;
import com.xbongbong.pro.formexplain.pojo.vo.FormExplainAddBatchVO;
import com.xbongbong.pro.fundset.pojo.FundSetTransitionPojo;
import com.xbongbong.pro.menu.pojo.dto.MenuGroupAddBatchDTO;
import com.xbongbong.pro.menu.pojo.dto.MenuInitDTO;
import com.xbongbong.pro.menu.pojo.vo.MenuGroupAddBatchVO;
import com.xbongbong.pro.menu.pojo.vo.MenuInitVO;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.MirrorModuleEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 资金管理应用生成和菜单初始化
 * @author 吴峰
 * @version v1.0
 * @date 2019/1/17 19:46
 * @since v1.0
 */
@Component
public class InitProductMenuHelp extends AbstractInitMenuHelp {

    private static final Logger LOG = LoggerFactory.getLogger(InitProductMenuHelp.class);

    @Resource
    private PaasMenuService paasMenuService;
    @Resource
    private PaasFormService paasFormService;
    @Resource
    private PaasFormExplainService paasFormExplainService;

    @Override
    public List<String> alias() {
        return Arrays.asList(SystemAppMenuEnum.PRODUCT.getAlias());
    }
    @Override
    public MenuInitVO initApp(MenuInitDTO menuInitDTO, Map<String, PaasAppEntity> appMap) throws XbbException {
        return new MenuInitVO();
    }

    /**
     * 资金管理菜单初始化
     * @author 吴峰
     * @date 2019/1/24 18:44
     * @param menuInitDTO
     * @return void
     * @throws XbbException
     */
    @Override
    public MenuInitVO initMenu(MenuInitDTO menuInitDTO, Map<String, PaasAppEntity> appMap) throws XbbException {
        MenuInitVO menuInitVO = new MenuInitVO();
        try {
            // 获取下应用id
            Long appId = appMap.get(SystemAppMenuEnum.PRODUCT.getAlias()).getId();
            menuInitDTO.setAppId(appId);
            // 插入菜单分组
            MenuGroupAddBatchVO crmGroupAddBatchVO = groupAddBatch(menuInitDTO);
            if(Objects.isNull(crmGroupAddBatchVO)){
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
            }

            List<PaasMenuEntity> menuGroupList = crmGroupAddBatchVO.getMenuList();
            List<PaasMenuEntity> menuList = new ArrayList<>();
            menuList.addAll(menuGroupList);
            // 插入菜单对应的表单
            FormAddBatchDTO formAddBatchDTO = new FormAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, formAddBatchDTO);
            List<FormEntityAddDTO> formList = new ArrayList<>();
            // 通过分组菜单，得到需要插入的表单列表
            getFormList(formList, menuList);
            //setRefProductForm(appId, formList,menuInitDTO.getCorpid(),menuInitDTO.getUserId());
            formAddBatchDTO.setFormList(formList);
            FormAddBatchVO formAddBatchVO = paasFormService.addBatch(formAddBatchDTO);
            if (Objects.isNull(formAddBatchVO)) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
            }
            // 插入表单对应的字段解释
            formExplainAddBatch(menuInitDTO, formAddBatchVO);
            menuInitVO.setFormList(formAddBatchVO.getFormList());
        } catch (XbbException e){
            throw e;
        } catch (Exception e){
            LOG.error("InitCrmMenuHelp.menuInit初始化菜单出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return menuInitVO;
    }

    @Override
    public void rollBackInit(MirrorRollBackDTO mirrorRollBackDTO, List<Long> installFormList, PaasFormEntity paasFormEntity) throws XbbException {

    }

    /**
     * 添加关联产品的form
     * @param appId
     * @param formList
     */
    public void setRefProductForm(Long appId, List<FormEntityAddDTO> formList,String corpid,String creatorId) {
        long now = DateUtil.getNow();
        for (BIProductEnum value : BIProductEnum.values()) {
            FormEntityAddDTO formEntityAddDTO = new FormEntityAddDTO();
            formEntityAddDTO.setBusinessType(value.getCode());
            formEntityAddDTO.setAppId(appId);
            formEntityAddDTO.setSaasMark(SaasMarkEnum.SAAS.getCode());
            formEntityAddDTO.setName(value.getName());
            formEntityAddDTO.setAddTime(now);
            formEntityAddDTO.setUpdateTime(now);
            formEntityAddDTO.setCorpid(corpid);
            formEntityAddDTO.setMenuId(0L);
            formEntityAddDTO.setCreatorId(creatorId);
            formList.add(formEntityAddDTO);
        }
    }


    /**
     * 添加表单字段解释
     * @author 吴峰
     * @date 2019/1/24 18:44
     * @param menuInitDTO
     * @param formAddBatchVO 表单数据
     * @return 返回表单字段对象
     * @throws XbbException
     */
    public FormExplainAddBatchVO formExplainAddBatch(MenuInitDTO menuInitDTO, FormAddBatchVO formAddBatchVO) throws XbbException {
        FormExplainAddBatchVO formExplainAddBatchVO;
        try {
            List<PaasFormEntity> formResultList = formAddBatchVO.getFormList();
            FormExplainAddBatchDTO formExplainAddBatchDTO = new FormExplainAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, formExplainAddBatchDTO);
            List<FormExplainAddDTO> formExplainList = new ArrayList<>();
            FundSetTransitionPojo fundSetTransitionPojo = new FundSetTransitionPojo(menuInitDTO.getCorpid());
            for (PaasFormEntity item : formResultList) {
                // 过滤掉bi的一些表单
                BIProductReformEnum biProductReformEnum = BIProductReformEnum.getEnumByProductBusinessType(item.getBusinessType());
                if (Objects.nonNull(biProductReformEnum) ||
                        Objects.equals(item.getBusinessType(), XbbRefTypeEnum.CONTRACT_PERFORMANCE.getCode())) {
                    continue;
                }
                FormExplainAddDTO formExplainAddDTO = new FormExplainAddDTO();
                BeanUtil.copyProperties(item, formExplainAddDTO);
                formExplainAddDTO.setFormId(item.getId());
                String alias = XbbRefTypeEnum.getByCode(item.getBusinessType()).getAlias();
                // 初始化方法获取字段列表
                List<FieldAttrEntity> explainList = new ArrayList<>();
                if (!InitExplainsHelper.EMPTY_EXPLAIN.contains(item.getBusinessType())) {
                    explainList = InitExplainsHelper.initFieldAttrEntity(alias, menuInitDTO.getProductForm(), fundSetTransitionPojo, 0);
                }
                formExplainAddDTO.setFormList(explainList);
                formExplainList.add(formExplainAddDTO);
            }
            formExplainAddBatchDTO.setFormExplainList(formExplainList);
            formExplainAddBatchVO = paasFormExplainService.addBatch(formExplainAddBatchDTO);
        } catch (XbbException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("InitCrmMenuHelp.formExplainAddBatch批量添加表单解释信息出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return formExplainAddBatchVO;
    }
    /**
     * 批量添加分组
     * @author 吴峰
     * @date 2019/1/24 18:43
     * @param menuInitDTO
     * @return com.xbongbong.pro.menu.pojo.vo.MenuGroupAddBatchVO
     * @throws XbbException
     */
    private MenuGroupAddBatchVO groupAddBatch(MenuInitDTO menuInitDTO) throws XbbException {
        MenuGroupAddBatchVO menuGroupAddBatchVO;
        try {
            Long appId = menuInitDTO.getAppId();
            MenuGroupAddBatchDTO menuGroupAddBatchDTO = new MenuGroupAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, menuGroupAddBatchDTO);
            menuGroupAddBatchDTO.setAppId(appId);
            List<MenuGroupAddDTO> groupMenuList = new ArrayList<>();
            for(ProductMenuEnum menuEnum: ProductMenuEnum.values()){
                if(StringUtil.isEmpty(menuEnum.getParent())){
                    MenuGroupAddDTO menuGroupAddDTO = new MenuGroupAddDTO();
                    BeanUtil.copyProperties(menuInitDTO, menuGroupAddDTO);
                    menuGroupAddDTO.setParentId(0L);
                    menuGroupAddDTO.setAppId(appId);
                    menuGroupAddDTO.setAlias(menuEnum.getAlias());
                    menuGroupAddDTO.setSaasMark(SaasMarkEnum.SAAS.getCode());
                    menuGroupAddDTO.setName(menuEnum.getName());
                    AccessLinkEnum accessLinkEnum = menuEnum.getAccessLinkEnum();
                    menuGroupAddDTO.setIcon(accessLinkEnum.getIcon());
                    menuGroupAddDTO.setColor(accessLinkEnum.getColor());
                    menuGroupAddDTO.setUrl(accessLinkEnum.getUrl());
                    menuGroupAddDTO.setMobileUrl(accessLinkEnum.getMobileUrl());
                    menuGroupAddDTO.setType(menuEnum.getType());
                    groupMenuList.add(menuGroupAddDTO);
                }
            }
            menuGroupAddBatchDTO.setMenuList(groupMenuList);
            menuGroupAddBatchVO = paasMenuService.addBatchGroupMenu(menuGroupAddBatchDTO);
        } catch (XbbException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("InitCrmMenuHelp.groupAddBatch批量添加分组出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return menuGroupAddBatchVO;
    }


    /**
     * 根据菜单获取表单列表
     * @author 吴峰
     * @date 2019/1/24 18:43
     * @param formList 表单列表
     * @param menuList 菜单列表
     * @return 返回需要插入的表单列表
     * @throws XbbException 业务异常
     */
    private List<FormEntityAddDTO> getFormList(List<FormEntityAddDTO> formList, List<PaasMenuEntity> menuList) throws XbbException{
        try {
            for (PaasMenuEntity item : menuList) {
                FormEntityAddDTO formEntityAddDTO = new FormEntityAddDTO();
                BeanUtil.copyProperties(item, formEntityAddDTO);
                ProductMenuEnum menuEnum = ProductMenuEnum.getByAlias(item.getAlias());
                if (Objects.isNull(menuEnum)) {
                    throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.BUSINESS_TYPE_NOT_EXIST);
                }
                if(MenuTypeEnum.GROUP.getType().equals(menuEnum.getType()) || MenuTypeEnum.MENU.getType().equals(menuEnum.getType())) {
                    continue;
                }
                formEntityAddDTO.setBusinessType(menuEnum.getCode());
                formEntityAddDTO.setSaasMark(SaasMarkEnum.SAAS.getCode());
                formEntityAddDTO.setCustomTitle(getAppDefaultTitle(menuEnum.getCode()));
                formEntityAddDTO.setLabels(getAppDefaultLabel(menuEnum.getCode()));
                formEntityAddDTO.setSummaryEntity(getAppDefaultSummary(menuEnum.getCode()));
                formEntityAddDTO.setBusinessRules("0");
                formEntityAddDTO.setMenuId(item.getId());
                formList.add(formEntityAddDTO);
            }
        }catch (XbbException e) {
            throw e;
        }
        return formList;
    }


    /**
     * CRM 简化版-产品菜单初始化
     * @author xingxing.xiao
     * @param menuInitDTO
     * @return void
     * @throws XbbException
     */
    public MenuInitVO initSimpleMenu(MenuInitDTO menuInitDTO, JSONObject mirrorObj) throws XbbException {
        MenuInitVO menuInitVO = new MenuInitVO();
        try {
            JSONObject menuObj = mirrorObj.getJSONObject(MirrorModuleEnum.MENU.getAlias());
            JSONArray productMenu = menuObj.getJSONArray(SystemAppMenuEnum.PRODUCT.getAlias());
            JSONObject formObj = mirrorObj.getJSONObject(MirrorModuleEnum.FORM.getAlias());
            JSONArray productForm = formObj.getJSONArray(SystemAppMenuEnum.PRODUCT.getAlias());
            JSONObject fieldObj = mirrorObj.getJSONObject(MirrorModuleEnum.FIELD.getAlias());

            // 获取应用id
            Long appId = menuInitDTO.getAppMap().get(SystemAppMenuEnum.PRODUCT.getAlias()).getId();
            menuInitDTO.setAppId(appId);

            // 1. 插入菜单分组
            MenuGroupAddBatchVO crmGroupAddBatchVO = groupSimpleAddBatch(menuInitDTO, productMenu);
            if(Objects.isNull(crmGroupAddBatchVO)){
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
            }

            // 2. 插入菜单对应的表单
            List<PaasMenuEntity> menuGroupList = crmGroupAddBatchVO.getMenuList();
            List<PaasMenuEntity> menuList = new ArrayList<>(menuGroupList);
            FormAddBatchDTO formAddBatchDTO = new FormAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, formAddBatchDTO);
            List<FormEntityAddDTO> formList = new ArrayList<>();
            // 通过分组菜单，得到需要插入的表单列表
            getSimpleFormList(formList, menuList, productForm);
            // 关联产品的form 默认开启，关闭可能会影响别的  2021/10/20这边把产品子表单隐藏的原因就是关联产品需求，逻辑变成主业务表插入之后再插入产品子表。有问题请找zcp和wtw确认
            //setRefProductForm(appId, formList,menuInitDTO.getCorpid(),menuInitDTO.getUserId());
            formAddBatchDTO.setFormList(formList);
            FormAddBatchVO formAddBatchVO = paasFormService.addBatch(formAddBatchDTO);
            if (Objects.isNull(formAddBatchVO)) {
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
            }
            // 3. 插入表单对应的字段解释
            formExplainSimpleAddBatch(menuInitDTO, formAddBatchVO, fieldObj);
            menuInitVO.setFormList(formAddBatchVO.getFormList());
        } catch (XbbException e){
            throw e;
        } catch (Exception e){
            LOG.error("InitCrmMenuHelp.menuInit初始化菜单出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return menuInitVO;
    }

    /**
     * 批量添加分组
     * @author xingxing.xiao
     * @param menuInitDTO
     * @return com.xbongbong.pro.menu.pojo.vo.MenuGroupAddBatchVO
     * @throws XbbException
     */
    private MenuGroupAddBatchVO groupSimpleAddBatch(MenuInitDTO menuInitDTO, JSONArray productMenu) throws XbbException {
        MenuGroupAddBatchVO menuGroupAddBatchVO;
        try {
            Long appId = menuInitDTO.getAppId();
            MenuGroupAddBatchDTO menuGroupAddBatchDTO = new MenuGroupAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, menuGroupAddBatchDTO);
            menuGroupAddBatchDTO.setAppId(appId);
            List<MenuGroupAddDTO> groupMenuList = new ArrayList<>();
            for(ProductMenuEnum menuEnum: ProductMenuEnum.values()){
                if(StringUtil.isEmpty(menuEnum.getParent())){
                    MenuGroupAddDTO menuGroupAddDTO = new MenuGroupAddDTO();
                    BeanUtil.copyProperties(menuInitDTO, menuGroupAddDTO);
                    menuGroupAddDTO.setParentId(0L);
                    menuGroupAddDTO.setAppId(appId);
                    menuGroupAddDTO.setAlias(menuEnum.getAlias());
                    menuGroupAddDTO.setSaasMark(SaasMarkEnum.SAAS.getCode());
                    menuGroupAddDTO.setName(menuEnum.getName());
                    AccessLinkEnum accessLinkEnum = menuEnum.getAccessLinkEnum();
                    menuGroupAddDTO.setIcon(accessLinkEnum.getIcon());
                    menuGroupAddDTO.setColor(accessLinkEnum.getColor());
                    menuGroupAddDTO.setUrl(accessLinkEnum.getUrl());
                    menuGroupAddDTO.setMobileUrl(accessLinkEnum.getMobileUrl());
                    menuGroupAddDTO.setType(menuEnum.getType());
                    if (productMenu == null || !productMenu.contains(menuEnum.getAlias())) {
                        // 镜像中没有配置的，默认关闭
                        menuGroupAddDTO.setEnable(0);
                    }
                    groupMenuList.add(menuGroupAddDTO);
                }
            }
            menuGroupAddBatchDTO.setMenuList(groupMenuList);
            menuGroupAddBatchVO = paasMenuService.addBatchGroupMenu(menuGroupAddBatchDTO);
        } catch (XbbException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("InitCrmMenuHelp.groupSimpleAddBatch批量添加分组出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return menuGroupAddBatchVO;
    }
    /**
     * 根据菜单获取表单列表
     * @author xingxing.xiao
     * @param formList 表单列表
     * @param menuList 菜单列表
     * @param productForm 表单镜像
     * @return 返回需要插入的表单列表
     * @throws XbbException 业务异常
     */
    private List<FormEntityAddDTO> getSimpleFormList(List<FormEntityAddDTO> formList, List<PaasMenuEntity> menuList, JSONArray productForm) throws XbbException{
        try {
            for (PaasMenuEntity item : menuList) {
                FormEntityAddDTO formEntityAddDTO = new FormEntityAddDTO();
                BeanUtil.copyProperties(item, formEntityAddDTO);
                ProductMenuEnum menuEnum = ProductMenuEnum.getByAlias(item.getAlias());
                if (Objects.isNull(menuEnum)) {
                    throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, MessageConstant.BUSINESS_TYPE_NOT_EXIST);
                }
                if(MenuTypeEnum.GROUP.getType().equals(menuEnum.getType()) || MenuTypeEnum.MENU.getType().equals(menuEnum.getType())) {
                    continue;
                }
                formEntityAddDTO.setBusinessType(menuEnum.getCode());
                formEntityAddDTO.setSaasMark(SaasMarkEnum.SAAS.getCode());
                formEntityAddDTO.setCustomTitle(getAppDefaultTitle(menuEnum.getCode()));
                List<BusinessRulesPoJo> businessRulesPoJos = new ArrayList<>();
                formEntityAddDTO.setBusinessRules("0");
                formEntityAddDTO.setMenuId(item.getId());
                if (productForm == null || !productForm.contains(menuEnum.getAlias())) {
                    // 镜像中没有配置的，默认关闭
                    formEntityAddDTO.setEnable(BasicConstant.NO_USE);
                }
                formList.add(formEntityAddDTO);
            }
        }catch (XbbException e) {
            throw e;
        }
        return formList;
    }

    /**
     * CRM简化版-添加表单字段解释
     * @author xingxing.xiao
     * @param menuInitDTO
     * @param formAddBatchVO 表单数据
     * @param fieldObj 字段镜像
     * @return 返回表单字段对象
     * @throws XbbException
     */
    public FormExplainAddBatchVO formExplainSimpleAddBatch(MenuInitDTO menuInitDTO, FormAddBatchVO formAddBatchVO, JSONObject fieldObj) throws XbbException {
        FormExplainAddBatchVO formExplainAddBatchVO;
        try {
            List<PaasFormEntity> formResultList = formAddBatchVO.getFormList();
            FormExplainAddBatchDTO formExplainAddBatchDTO = new FormExplainAddBatchDTO();
            BeanUtil.copyProperties(menuInitDTO, formExplainAddBatchDTO);
            List<FormExplainAddDTO> formExplainList = new ArrayList<>();
            FundSetTransitionPojo fundSetTransitionPojo = new FundSetTransitionPojo(menuInitDTO.getCorpid());
            for (PaasFormEntity item : formResultList) {
                // 过滤掉bi的一些表单
                BIProductEnum biProductEnum = BIProductEnum.getByCode(item.getBusinessType());
                if (Objects.nonNull(biProductEnum) ||
                        Objects.equals(item.getBusinessType(), XbbRefTypeEnum.CONTRACT_PERFORMANCE.getCode())) {
                    continue;
                }
                FormExplainAddDTO formExplainAddDTO = new FormExplainAddDTO();
                BeanUtil.copyProperties(item, formExplainAddDTO);
                formExplainAddDTO.setFormId(item.getId());
                String alias = XbbRefTypeEnum.getByCode(item.getBusinessType()).getAlias();
                // 获取表单对应的字段镜像
                JSONArray fieldArray = fieldObj.getJSONArray(alias);
                // 初始化方法获取字段列表
                formExplainAddDTO.setFormList(InitExplainsHelper.initSimpleFieldAttrEntity(alias, fieldArray, menuInitDTO.getProductForm(), fundSetTransitionPojo));
                // 默认启用，防止不启用的菜单覆盖
                formExplainAddDTO.setEnable(1);
                formExplainList.add(formExplainAddDTO);
            }
            formExplainAddBatchDTO.setFormExplainList(formExplainList);
            formExplainAddBatchVO = paasFormExplainService.addBatch(formExplainAddBatchDTO);
        } catch (XbbException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("InitCrmMenuHelp.formExplainSimpleAddBatch批量添加表单解释信息出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
        return formExplainAddBatchVO;
    }

}
